﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using AspNetCs.Common;
using AspNetCs.Bll;
using AspNetCs.Model;
using AspNetCs.Enumerations;

public partial class Master_Admin_AgentFillPoint : Admin_BasePage
{
    private int id = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindUsers();
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        AddPoint();
        ResultStr("Admin_AddPoint.Aspx", "充值成功!");
        //Response.Redirect("Admin_AddPoint.Aspx");
    }

    public void AddPoint()
    {
        Point_Log_Model Point_Logmodel = new Point_Log_Model();
        Point_Logmodel.NetIp = StringHelper.Ip();
        Point_Logmodel.Point = -(StringHelper.isNumber_int(txtNum.Text));
        if (ddluserId.Items.Count == 0)
        {
            return;
        }
        Point_Logmodel.UserId = StringHelper.isNumber_int(ddluserId.SelectedValue);
        int userType = (int)UserTypeEnum.Agent;
        Point_Logmodel.UserType = userType;
        Point_Logmodel.Addtime = DateTime.Now;

        if (ddluserId.SelectedValue == "0")
        {
            Point_Logmodel.Readme = "管理员给所有代理商充值:" + Point_Logmodel.Point + "点";

        }
        else
        {
            Point_Logmodel.Readme = "管理员给代理商充值:" + Point_Logmodel.Point + "点";
        }
        Point_Log_Bll.CreateNew.Add(Point_Logmodel);


    }

    public void BindUsers()
    {
        DataTable dataTable1 = Agen_BLL.CreateNew.GetDataTable("");
        ddluserId.DataSource = dataTable1;
        ddluserId.DataTextField = "AgentUserName";
        ddluserId.DataValueField = "id";
        ddluserId.DataBind();
        ddluserId.Items.Insert(0, new ListItem("所有代理商", "0"));

    }
    protected void ddlUserType_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindUsers();
    }
}
